# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import List
from fastapi import APIRouter, Depends
from hypertext import R, PagingResult, response_json
from apps.admin.schemas.square import category_schema as schema
from apps.admin.service.square.category_service import SquareCategoryService

router = APIRouter(prefix="/category", tags=["广场分类接口"])


@router.get("/whole", summary="所有分类", response_model=R[List[schema.SquareCategoryListVo]])
@response_json
async def whole(params: schema.SquareCategorySearchIn = Depends()):
    return await SquareCategoryService.whole(params)


@router.get("/lists", summary="分类列表", response_model=R[PagingResult[schema.SquareCategoryListVo]])
@response_json
async def lists(params: schema.SquareCategorySearchIn = Depends()):
    return await SquareCategoryService.lists(params)


@router.get("/detail", summary="分类详情", response_model=R[schema.SquareCategoryDetailVo])
@response_json
async def detail(params: schema.SquareCategoryDetailIn = Depends()):
    return await SquareCategoryService.detail(params.id)


@router.post("/add", summary="分类新增", response_model=R)
@response_json
async def add(params: schema.SquareCategoryAddIn):
    return await SquareCategoryService.add(params)


@router.post("/edit", summary="分类编辑", response_model=R)
@response_json
async def edit(params: schema.SquareCategoryEditIn):
    return await SquareCategoryService.edit(params)


@router.post("/delete", summary="分类删除", response_model=R)
@response_json
async def delete(params: schema.SquareCategoryDeleteIn):
    return await SquareCategoryService.delete(params.id)
